package com.unitechs.controller.map;

import com.unitechs.commons.utils.ZyucMapUtil;
import com.unitechs.controller.DevinfoTest;


import java.util.*;

public class MapTestMain {
    public static void main(String[] args) {
        List<DevinfoTest> devInfos =new ArrayList<>();

        for (int i=0;i<10;i++){
            DevinfoTest devInfo = new DevinfoTest();
            devInfos.add(devInfo);
            devInfo.setDevid("RD0000"+i);
            devInfo.setDevname(UUID.randomUUID().toString());
            devInfo.setNodeid("ND0000"+i);
            devInfo.setDevtype("路由器");
        }


        Map<String, DevinfoTest> map =listToMap(devInfos);
        System.out.println(map);
        System.out.println(map.get("RD00001"));

        System.out.println();


        Map<Object, DevinfoTest> devid = ZyucMapUtil.zyucSetCollectionToMap(devInfos, "devid");


        System.out.println(devid);
        System.out.println(devid.get("RD00001"));
    }


    public static Map<String,DevinfoTest> listToMap(List<DevinfoTest> list){
        Map<String,DevinfoTest> map=new HashMap<>();
        for (DevinfoTest devInfo:list){
            map.put(devInfo.getDevid(),devInfo);
        }
        return map;
    }

}

